/*
 * personal.h
 *
 *  Created on: May 15, 2011
 *      Author: A126872
 */

#ifndef FILE_HANDLER_H_
#define FILE_HANDLER_H_

#include "constantes.h"

typedef int (*pComparatorFunction)(void *, void *);
typedef int (*pIsItemEmptyFunction)(void *);
typedef void (*pClearItemFunction)(void *);

typedef struct _file_ {
	FILE * file;
	size_t itemSize;
	pComparatorFunction pComparator;
	pIsItemEmptyFunction pIsItemEmpty;
	pClearItemFunction pClearItem;
} _file_t ;

typedef _file_t * file_handler_t;


file_handler_t fh_open(char * fichero, int itemSize, pComparatorFunction pComparator, pIsItemEmptyFunction pIsItemEmpty, pClearItemFunction pClearItem);
int fh_add_item(file_handler_t file_handler, void * item );
int fh_remove_item(file_handler_t file_handler, void * item );
int fh_modify_item(file_handler_t file_handler, void * item );
int fh_find_item(file_handler_t file_handler, void * item );

//int fh_find_items(file_handler_t file_handler, trabajador_t * ptrabajador, int * numTrabajadores);
//int fh_find_items_by_criteria(FILE * ficheroTrabajadores, char * puesto, trabajador_t * ptrabajador, int * numTrabajadores);

int fh_close(file_handler_t file_handler);


#endif /* FILE_HANDLER_H_ */
